var opinionPrice;

/**
 * 设置结果接收对象
 * @param _opinionPrice
 */
function setModel(_opinionPrice) {
    if (_opinionPrice == undefined || !(_opinionPrice instanceof com.jf.crawl.model.OpinionPrice)) {
        throw new java.lang.Exception("opinionPrice 对象为空");
    }
    log.info("opinionPrice {}", _opinionPrice)
    opinionPrice = _opinionPrice;
}

//3个月--6.00%
//6个月--7.00%
//12个月--8.50%
//24个月--10.00%
function crawler() {
    var headers = new LinkedHashMap();
    headers.put("Accept", " textml,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
    headers.put("Accept-Encoding", "gzip, deflate, br");
    headers.put("Accept-Language", "zh-CN,zh;q=0.8");
    headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");
    var html = Get("https://m.yooli.com/dingcunbao/index.do", headers, "utf-8");
    var doc = Jsoup.parse(html);
    var items = doc.select(".items");
    //从第2个开始 去除新手优惠
    for (var i = 1; i < items.size(); i++) {
        var item = items.get(i);
        var month = item.select("li.c2 > .git.time").text();
        var price = item.select("li.c1 > .git.per").text().trim().replace("%", "");
        if (price.contains("+")) {
            a = price.split("+")[0];
            b = price.split("+")[1].replace("%","");
            price = Number(a) + Number(b);
        }
        if ("1个月".equals(month)) {
            opinionPrice.setOneMonth(commonUtil.string2Decimal(price));
        } else if ("3个月".equals(month)) {
            opinionPrice.setThreeMonth(commonUtil.string2Decimal(price));
        } else if ("6个月".equals(month)) {
            opinionPrice.setSixMonth(commonUtil.string2Decimal(price));
        } else if ("12个月".equals(month)) {
            opinionPrice.setOneYear(commonUtil.string2Decimal(price));
        } else if ("24个月".equals(month)) {
            opinionPrice.setTwoYear(commonUtil.string2Decimal(price));
        } else if ("36个月".equals(month)) {
            opinionPrice.setThreeYear(commonUtil.string2Decimal(price));
        }
    }
    return true;
}